<template>
  <div class="period-list" :style="{height: contentHeight+'px'}">
    <ul class="u-list">
      <li class="l-item" v-for="(item,index) in periodList" :key="index">
        <div class="item-wrap">
          <div class="item-l">
            <img :src="item.cover" alt="封面">
          </div>
          <div class="item-r">
            <div class="title">{{item.title}}</div>
            <div class="release-date">{{item.issuedDate}}</div>
            <div class="hot">
              <template v-for="n in item.totalHot">
                <img
                  :src="n > item.hot ? require('../assets/image/hot.png') : require('../assets/image/hot_h.png')"
                  :alt="n"
                  :key="n"
                >
              </template>
            </div>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
const periodList = [
  {
    id: 1,
    title: '禾苗内刊 | 2018年度第12期',
    issuedDate: '2018.12.01-2018.12.31',
    cover: require('../assets/image/covertest1.png'),
    totalHot: 5,
    hot: 3
  },
  {
    id: 2,
    title: '禾苗内刊 | 2018年度第11期',
    issuedDate: '2018.12.01-2018.12.31',
    cover: require('../assets/image/covertest2.png'),
    totalHot: 5,
    hot: 2
  },
  {
    id: 3,
    title: '禾苗内刊 | 2018年度第10期',
    issuedDate: '2018.12.01-2018.12.31',
    cover: require('../assets/image/covertest3.png'),
    totalHot: 5,
    hot: 4
  },
  {
    id: 4,
    title: '禾苗内刊 | 2018年度第9期',
    issuedDate: '2018.12.01-2018.12.31',
    cover: require('../assets/image/covertest1.png'),
    totalHot: 5,
    hot: 1
  }
]
export default {
  name: 'PeriodList',
  data () {
    return {
      periodList
    }
  },
  computed: {
    contentHeight () {
      return this.$store.state.periodHeight
    }
  },
  methods: {}
}
</script>
<style lang="less">
  .period-list {
    position: relative;
    // todo done compute height
    overflow: hidden;
    .u-list {
      list-style: none;
      position: absolute;
      left: 0;
      right: 0;
      height: 100%;
      overflow-y: scroll;
      background: #f4fffd;
      box-sizing: border-box;
      padding-top: 10px;
      .l-item {
        .item-wrap {
          border: 15px solid #f4fffd;
          box-sizing: border-box;
          width: 100%;
          display: flex;
          // background: #fff;
          background: #fbfffe;
          border-radius: 20px;

          .item-l {
            flex: 1.2;
            padding: 15px 3px;
            img {
              width: 100%;
              height: 100%;
              object-fit: cover;
              border-radius: 15px;
            }
          }
          .item-r {
            flex: 3;
            padding: 15px;
            display: flex;
            flex-flow: column nowrap;
            justify-content: space-between;
            .title {
              font-size: 16px;
              color: #333;
            }
            .release-date {
              font-size: 11px;
              color: #777;
            }
            .hot {
              img {
                width: 15px;
                height: 17px;
              }
            }
          }
        }
      }
    }
  }
</style>
